#include<stdio.h>
#include<string.h>

//交换字符串首尾


void Reserve( char* const a,int len)
{
    
    for(int i=0; i < len/2;i++)
    {
        char temp = {0};


            temp = a[i] ;
            a[i] = a[len-1-i];
            a[len-1-i] = temp;
     
    }
    
}




void Reserve2(char*const a,int len)
{
    int count=0;
    
            
    for(int i = 0; i < len ;i++)
    {
        if(a[i] == '\0' || a[i] == ' ')
        { Reserve(a+i-count,count);
            count=0;
        }
           
        else
        count++;
    }
    
}


int main()
{

    char s[] ="i am from nanjing";
    Reserve(s,strlen(s));
    printf("%s\n",s);
    Reserve2(s,strlen(s));
    printf("%s\n",s);
    


    return 0;
}       